Skip to content

Conversation

@user202729
Copy link
Contributor

@user202729 user202729 commented Dec 15, 2025

Supposedly this version does not copy, while the previous one copies the fmpz.

Sometimes a temporary variable is needed so that the Integer object does not get destroyed (thus destroying the underlying mpz) during the time the fmpz is used.

There are a few other occurrences in other places, as well as fmpq_init_set_readonly, but we can start with this.

📝 Checklist

  • The title is concise and informative.
  • The description explains in detail what this PR is about.
  • I have linked a relevant issue or discussion.
  • I have created tests covering the changes.
  • I have updated the documentation and checked the documentation preview.

⌛ Dependencies

@user202729 user202729 marked this pull request as ready for review December 15, 2025 08:16
@github-actions
Copy link

Documentation preview for this PR (built with commit 7980dbf; changes) is ready! 🎉
This preview will update shortly after each push to this PR.

@cxzhong
Copy link
Contributor

cxzhong commented Dec 15, 2025

I think it is faster than before

vbraun pushed a commit to vbraun/sage that referenced this pull request Dec 20, 2025
sagemathgh-41295: Use fmpz_init_set_readonly at several places
    
Supposedly this version does not copy, while the previous one copies the
fmpz.

Sometimes a temporary variable is needed so that the `Integer` object
does not get destroyed (thus destroying the underlying `mpz`) during the
time the `fmpz` is used.

There are a few other occurrences in other places, as well as
`fmpq_init_set_readonly`, but we can start with this.

### 📝 Checklist

<!-- Put an `x` in all the boxes that apply. -->

- [ ] The title is concise and informative.
- [ ] The description explains in detail what this PR is about.
- [ ] I have linked a relevant issue or discussion.
- [ ] I have created tests covering the changes.
- [ ] I have updated the documentation and checked the documentation
preview.

### ⌛ Dependencies

<!-- List all open PRs that this PR logically depends on. For example,
-->
<!-- - sagemath#12345: short description why this is a dependency -->
<!-- - sagemath#34567: ... -->
    
URL: sagemath#41295
Reported by: user202729
Reviewer(s):
@vbraun vbraun merged commit 5564265 into sagemath:develop Dec 21, 2025
23 of 24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants